{include file="public/header"/}
<link rel="stylesheet" href="{__PUBLIC_PATH}/admin/pcf/pcfcms.css?v={$version}"/>
</head>
<body>
<style type="text/css">
.hDiv{background-color:#f7f7f7;clear:both;border:1px solid #f7f7f7;border-bottom:none;margin-bottom:20px;}
.pcfts{font: bold 14px/20px tahoma,verdana;color:#F60;vertical-align:middle;display:inline-block;margin-right:5px;margin-left:-14px;}
.anchor-icon{display:inline-block;width: 22px;height: 20px;background-color: red;margin-right: 6px;vertical-align: middle;}
.anchor-icon-biao{background: url(/admin/assets/images/icon-copying-norm.png) no-repeat;}
</style>
<div class="layui-form">
<div class="layui-fluid" style="padding-bottom:83px;border:0;">
<div class="layui-col-sm12">
<div class="layui-card" style="box-shadow:0 0 0 0;">			
	<div class="layui-tab layui-tab-brief" id="pcfsystem">
	<ul class="layui-tab-title" style="background-color:#f2f2f2;">
		<a href="{:url('/system.web/index')}"><li>网站设置</li></a>
		<a href="{:url('/system.web/web2')}"><li>核心设置</li></a>
		<a href="{:url('/system.web/basic')}"><li>附件设置</li></a>
        <a href="{:url('/system.web/weapp_email')}"><li>邮箱配置</li></a>
        <a href="{:url('/system.web/weapp_sms')}"><li class="layui-this">短信配置</li></a>
        <a href="{:url('/system.web/weapp_pay')}" style="display:none;"><li>支付配置</li></a>
        <a href="{:url('/system.web/weapp_social')}" style="display:none;"><li>第三方登录配置</li></a>
	</ul>	
	<div class="layui-card-body">
		<div class="layui-form-item layui-row">
			<form id="sendsms">
				<div class="layui-card-header hDiv"><i class="anchor-icon anchor-icon-biao"></i>短信配置QQ登录配置 <font style="color:red;">(申请地址：http://www.28inter.com)</font></div>
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width:100px;">状态</label>
                    <div class="layui-input-block">
                        <input type="checkbox" name="sms_syn_weapp" lay-filter="sms_syn_weapp" value="{$config.sms_syn_weapp|default='0'}" lay-skin="switch" lay-text="开启|关闭" {notempty name="$config.sms_syn_weapp"}checked{/notempty}>
                    </div>
                </div>
				<div class="layui-form-item">
					<label class="layui-form-label" style="width:100px;"><b class="pcfts">*</b> 选择短信平台</label>
					<div class="layui-input-inline">
						<select name="sms_platform" id="sms_platform">
							<option value="1">创信短信</option>
						</select>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label" style="width:100px;padding-top:0px;"><b class="pcfts">*</b> 短信平台[appkey]</label>
					<div class="layui-input-inline">
						<input type="text" name="sms_appkey" id="sms_appkey" lay-verify="required" value="{$config.sms_appkey}" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label" style="width:100px;padding-top:0px;"><b class="pcfts">*</b> 短信平台[secretKey]</label>
					<div class="layui-input-inline">
						<input type="password" name="sms_secretkey" id="sms_secretkey" lay-verify="required" value="{$config.sms_secretkey}" class="layui-input">
					</div>
				</div>		
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width:100px;"> 短信内容</label>
                    <div class="layui-input-inline">
                        <textarea name="sms_content" id="sms_content" class="layui-textarea">{$config.sms_content}</textarea>
                    </div>
                </div>  			
				<div class="layui-form-item">
					<label class="layui-form-label" style="width:100px;">测试短信</label>
					<div class="layui-input-inline">
						<input type="text" name="sms_test" id="sms_test" value="{$config.sms_test}" class="layui-input">
					</div>
					<button class="layui-btn" lay-submit="sendSms" lay-filter="sendSms">发送</button>
				</div>
			</form>
		</div>
	</div>
</div>		
</div>
</div>
<div class="pcfclear"></div>
</div>
<div class="submit-info text-center">
    <button class="layui-btn" lay-submit="smsSubmit" lay-filter="smsSubmit">确认提交</button>
</div>
<div class="pcfclear"></div>
</div>
{include file="public/footer"/}
<script>
    layui.use(['layer', 'form'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;

        // 监听开关
        form.on('switch', function(data){
            var elemId = data.elem.attributes['lay-filter']['nodeValue'];
            if (data.elem.checked) {
                this.value = 1;
            } else {
                this.value = 0;
            }
            $("#"+elemId).val(this.value);
        });

		form.on('submit(sendSms)', function(data) {
			if (data.field.sms_test == '') {
				layer.msg('接收手机号码不能为空！', {time:1000});
				$('input[name=sms_test]').focus();
				return false;
			} else {
				layer.msg('正在处理请勿刷新页面', {icon: 16,shade: 0.01,time:3600000});
				$.ajax({
					type: "post",
					data: {mobile:data.field.sms_test},
					dataType: 'json',
					url: "{:url('/system.web/send_sms')}",
					success: function(res) {
						layer.closeAll();
						if(res.status){
							layer.msg(res.msg, {icon:1,time:1000});
						}else{
						    layer.msg(res.msg, {icon:2,time:1000});
						}
					},
					error: function() {
						layer.closeAll();
						layer.msg("网络中断！", {icon: 2,time:1000});
					}
				})
			}
			return false;
		});
		
        //监听提交
        form.on('submit(smsSubmit)', function(data){
            layer.msg('正在处理请勿刷新页面', {icon: 16,shade: 0.01});
            $.ajax({
                type : 'post',
                url : "{:url('/system.web/weapp_sms')}",
                data : $('#sendsms').serialize(),
                dataType : 'json',
                success : function(res){
                    layer.closeAll();
                    if(res.status){
                        layer.msg(res.msg, {icon:1,time:1000}, function(){
                            window.location.reload();
                        });
                    }else{
                       layer.msg(res.msg, {icon:2,time:1000});
                    }
                },
                error: function(e){
                    layer.closeAll();
                    layer.msg("网络中断！", {icon: 2,time:1000});
                }
            });
            return false;
        });
    });
</script>
</body>
</html>